package edu.mobbuzz.daf.facade;

import java.util.ArrayList;
import java.util.List;

import edu.mobbuzz.daf.bean.Rss;
import edu.mobbuzz.daf.dao.IRssDao;

public class RssFacade extends BaseFacade {
	private IRssDao rssDao;
	
	public IRssDao getRssDao() {
		if(rssDao==null)
			rssDao = (IRssDao)getFactory().getBean("rssDao");
		return rssDao;
	}
	
	public List<Rss> displayRssList(String where, String order){
		List<Rss> rssList = getRssDao().queryForList(where, order);
		
		if(rssList==null){
			rssList = new ArrayList<Rss>();
			return rssList;			
		}else{
			return rssList;
		}
	}
	
	public boolean addRss(String url){
		Rss _rss = new Rss();
		_rss.setUrl(url);
		
		try{
			getRssDao().insert(_rss);
			return true;
		}catch (Exception e) {
			return false;
		}
		
	}
	
	public boolean checkRSSExist(String rss){
		Rss _rss = (Rss)getRssDao().findByPrimaryKey(rss);
		if(_rss!=null){
			return true;
		}else{
			return false;
		}
		
	}
}
